<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>

    <%@include file="common/head-wangeditor.jsp" %>

</head>

<body>

<%@include file="common/sidebar-user.jsp" %>

<c:choose>
    <c:when test="${article == null}">
    <div class="main-content">
        <div class="fluid-container">
            <div class="content-wrapper">

                <div class="page-section">
                    <div class="row">
                        <div class="col-md-12">
                            <h4 class="widget-title">SEARCH 搜索</h4>

                            <%@include file="common/search.jsp" %>

                            <p class="text-center" style="margin-top: 80px">系统查询不到该博文的信息</p>
                        </div>
                    </div>
                </div>
                <hr>

                <%@include file="common/footer.jsp" %>

            </div>
        </div>
    </div>
    </c:when>
    <c:when test="${article != null}">
        <div class="main-content">
            <div class="fluid-container">
                <div class="content-wrapper">
                    <div class="page-section">

                        <div class="row">
                            <div class="col-md-12">
                                <div class="articleContent">${article.articleContent}</div>
                                <p><i class="fa fa-clock-o"></i> 发表于：${article.articleCreateDate} <i
                                        class="fa fa-eye"></i> 浏览：${article.articleViews}</p>
                            </div>
                        </div>
                        <shiro:hasRole name="admin">
                            <div class="row text-center" style="margin-top: 20px">
                                <button type="button"
                                        onclick="window.location.href='/articleManage/getArticle?articleId=${article.articleId}'"
                                        class="btn btn-primary">编 辑
                                </button>
                                <button type="button" onclick="window.location.href='/articleManage/articleList'"
                                        class="btn btn-primary">博文管理
                                </button>
                            </div>
                        </shiro:hasRole>
                    </div>
                    <hr/>

                    <div class="page-section">
                        <div class="row">
                            <div class="col-md-12">
                                <h4 class="widget-title">COMMENT 评论</h4>
                                <form>
                                    <div class="form-group text-center">
                                        <shiro:notAuthenticated>
                                            <button type="button" class="btn btn-primary"
                                                    onclick="window.location.href='/login'">登 录
                                            </button>
                                            <button type="button" class="btn btn-primary"
                                                    onclick="window.location.href='/register'">注 册
                                            </button>
                                        </shiro:notAuthenticated>
                                        <shiro:authenticated>
                                            <button type="button" class="btn btn-primary"
                                                    onclick="window.location.href='/logout'">退出登录
                                            </button>
                                        </shiro:authenticated>
                                    </div>
                                    <div class="form-group">
                                        <textarea class="form-control" rows="5"
                                                  placeholder="如果博文有什么问题请评论告诉，或者给我留言..."></textarea>
                                    </div>
                                    <div class="form-group text-center">
                                        <button type="button" class="btn btn-primary">发表评论</button>
                                    </div>
                                    <div class="form-group">
                                        <div class="panel panel-default" style="min-height: 500px">
                                            <div class="panel-body">
                                                <c:choose>
                                                    <c:when test="${commentVoList == null}">
                                                        <div class="text-center default-message"
                                                             style="margin-top: 150px">该文章还没有留言
                                                        </div>
                                                    </c:when>
                                                    <c:when test="${commentVoList != null}">
                                                        <dl class="dl-horizontal">
                                                            <c:forEach items="${commentVoList}" var="commentVo">
                                                                <dt>${commentVo.comment.commentUserId}：</dt>
                                                                <dd>
                                                                        ${commentVo.comment.commentContent}<span
                                                                        class="pull-right"><i
                                                                        class="fa fa-clock-o"></i> ${commentVo.comment.commentDate} <a
                                                                        href="">回复</a></span>
                                                                <dd>
                                                                <c:forEach
                                                                        items="${commentVoList.get(status.index).commentList}"
                                                                        var="comment">
                                                                    <dd><strong>${comment.commentUserId}</strong> @
                                                                        <strong>${commentVo.comment.commentUserId}：</strong>
                                                                    </dd>
                                                                    <dd>${comment.commentContent}<span
                                                                            class="pull-right"><i
                                                                            class="fa fa-clock-o"></i> ${comment.commentDate} <a
                                                                            href="">回复</a></span></dd>
                                                                </c:forEach>
                                                                <hr style="position: relative;
                                            outline: 0;
                                            border: 0;
                                            width: 100%;
                                            height: 1px;
                                            background: #dddddd;
                                            margin: 15px auto;"/>
                                                            </c:forEach>
                                                        </dl>
                                                    </c:when>
                                                </c:choose>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <hr>

                    <%@include file="common/footer.jsp" %>

                </div>

            </div>
        </div>
    </c:when>
</c:choose>

<%@include file="common/end.jsp" %>

<%@include file="common/sidebar-article-list.jsp" %>

</body>

</html>